#!/bin/bash

echo -e "\e[31m please buy Double Ball:\e[0m"
red=($(seq -s " " 1 33))
echo "Redball:" 
echo ${red[@]}
blue=($(seq -s " " 1 16))
echo "Blueball:"
echo ${blue[@]} 

for i in  $(seq 6)
do
        ran1=$((RANDOM%${#red[@]}))
        hq[x++]=${red[ran1]}
        unset red[ran1]
        red=(${red[@]})
done

ran2=$((RANDOM % 16 ))
bb=${lanqiu[ran2]}

echo -e "the lucky number is：\e[31m Redball：${red[@]}\e[0m 蓝球:\e[34m$bb\e[0m"
k=0
while true
do
        read -p "please 6 numbers (1-33)：" red1 red2 red3 red4 red5 red6
        read -p "please 1 number (1-16)：" blue1
        (( k++ ))
        if (( $blue1 != $bb ))
        then
                echo "太可惜了，你没有中奖，您已购买$k次，欢迎再次购买！"
        else
                echo "$red1 $red2 $red3 $red4 $red5 $red6" >1.txt
                echo "${hq[@]}" >2.txt
                if cat 2.txt|grep $red1|grep $red2|grep $red3|grep $red4|grep $red5|grep $red6 &>/dev/null
                then
                        echo "恭喜您，获得500万大奖"
                        break
                else
                        echo "太可惜了，你没有中奖"
		fi
fi
